package com.hundsun.cprs.yyt.service.order.domain;

import java.math.BigDecimal;

import com.hundsun.cprs.yyt.common.base.DomainBase;

public class OrderItem extends DomainBase{
    private Long id;

    private Long orderId;

    private Long goodsId;
    
    private String goodsCode;

    private String goodsName;

    private Integer quantity;

    private Long returnedQuantity=0L;//退货数量

    private Long shippedQuantity=0L;//已售数量
    
    private Long costPrice;//零售价

    private Long price;//实际售卖价格，批发区的折扣价，零售区的零售价
    
    private Long quotaAmount;

    private String thumbnail;

    private Long skuId;
    
    private Double quotaRewardRate;//配额奖励比例
    
    private Long quotaRewardAmount;

    private Double integralRewardRate;//积分奖励比例
    
    private Long integralRewardAmount;
    
    private Integer fixQuota;

    private Long rewardQuotaId;

    private Long payQuotaId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Long goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName == null ? null : goodsName.trim();
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Long getPrice() {
        return price;
    }

    public void setPrice(Long price) {
        this.price = price;
    }

    public String getThumbnail() {
        return thumbnail;
    }

    public void setThumbnail(String thumbnail) {
        this.thumbnail = thumbnail == null ? null : thumbnail.trim();
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public Double getQuotaRewardRate() {
        return quotaRewardRate;
    }

    public void setQuotaRewardRate(Double quotaRewardRate) {
        this.quotaRewardRate = quotaRewardRate;
    }

    public Double getIntegralRewardRate() {
        return integralRewardRate;
    }

    public void setIntegralRewardRate(Double integralRewardRate) {
        this.integralRewardRate = integralRewardRate;
    }

    public Long getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(Long costPrice) {
        this.costPrice = costPrice;
    }

    public String getGoodsCode() {
        return goodsCode;
    }

    public void setGoodsCode(String goodsCode) {
        this.goodsCode = goodsCode;
    }

    public Long getReturnedQuantity() {
        return returnedQuantity;
    }

    public void setReturnedQuantity(Long returnedQuantity) {
        this.returnedQuantity = returnedQuantity;
    }

    public Long getShippedQuantity() {
        return shippedQuantity;
    }

    public void setShippedQuantity(Long shippedQuantity) {
        this.shippedQuantity = shippedQuantity;
    }

    public Long getQuotaRewardAmount() {
        return quotaRewardAmount;
    }

    public void setQuotaRewardAmount(Long quotaRewardAmount) {
        this.quotaRewardAmount = quotaRewardAmount;
    }

    public Long getIntegralRewardAmount() {
        return integralRewardAmount;
    }

    public void setIntegralRewardAmount(Long integralRewardAmount) {
        this.integralRewardAmount = integralRewardAmount;
    }

    public Long getQuotaAmount() {
        return quotaAmount;
    }

    public void setQuotaAmount(Long quotaAmount) {
        this.quotaAmount = quotaAmount;
    }
    
    /**
     * 设置奖励比例，并计算奖励额
     * @param integralRewardRate
     */
    public void addIntegralRewardRate(Double integralRewardRate){
        Double rewardRate = integralRewardRate == null?0d:integralRewardRate;
        setIntegralRewardRate(rewardRate);
        setIntegralRewardAmount(new BigDecimal(rewardRate).movePointLeft(2)
                .multiply(new BigDecimal(getPrice()))
                .multiply(new BigDecimal(getQuantity()))
                .divide(new BigDecimal(100))
                .longValue());
    }
    
    /**
     * 设置奖励比例，并计算奖励额
     * @param quotaRewardRate
     */
    public void addQuotaRewardRate(Double quotaRewardRate){
        Double rewardRate = quotaRewardRate == null?0d:quotaRewardRate;
        setQuotaRewardRate(rewardRate);
        setFixQuota(new BigDecimal(rewardRate).movePointLeft(2)
                .multiply(new BigDecimal(getPrice()))
                .divide(new BigDecimal(100))
                .intValue());
        setQuotaRewardAmount(new BigDecimal(rewardRate).movePointLeft(2)
                .multiply(new BigDecimal(getPrice()))
                .divide(new BigDecimal(100))
                .multiply(new BigDecimal(getQuantity()))
                .longValue());
    }
    
    public void addQuotaRewardAmount(Integer fixQuota) {
    	setQuotaRewardRate(0d);
    	setFixQuota(fixQuota == null?0:fixQuota);
    	setQuotaRewardAmount(new BigDecimal(getFixQuota())
                .multiply(new BigDecimal(getQuantity()))
                .longValue());
    }

	public Integer getFixQuota() {
		return fixQuota;
	}

	public void setFixQuota(Integer fixQuota) {
		this.fixQuota = fixQuota;
	}

	public Long getRewardQuotaId() {
		return rewardQuotaId;
	}

	public void setRewardQuotaId(Long rewardQuotaId) {
		this.rewardQuotaId = rewardQuotaId;
	}

	public Long getPayQuotaId() {
		return payQuotaId;
	}

	public void setPayQuotaId(Long payQuotaId) {
		this.payQuotaId = payQuotaId;
	}
}